import java.util.Scanner;

public class Day_21_1_洗牌 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int m = scan.nextInt();
            while(m != 0) {
                int n = scan.nextInt();
                int k = scan.nextInt();
                int[] arr = new int[2*n];
                /**
                 * 1 2 3 4 5 6
                 * 洗牌一次：
                 * 1 4 2 5 3 6
                 *
                 * 对于n/2de牌，洗牌后位置变化:
                 * 洗牌前0 洗牌后0
                 * 洗牌前1 洗牌后2
                 * 洗牌前2 洗牌后4
                 * 相当于 (2 * 下标)
                 * 洗牌前3 洗牌后1
                 * 洗牌前4 洗牌后3
                 * 洗牌前5 洗牌后5
                 * 相当于 (2 * (下标-n) + 1)
                 */
                for(int i = 0; i < 2 * n; i++) {
                    int temp = i;
                    for(int j = 0; j < k; j++) {
                        if(temp < n) {
                            temp = 2 * temp;
                        }else {
                            temp = 2 * (temp-n) + 1;
                        }
                    }
                    arr[temp] = scan.nextInt();
                }
                for(int i = 0; i < 2 * n; i++) {
                    if(i == 2 * n - 1) {
                        System.out.print(arr[i]);
                    }else {
                        System.out.print(arr[i] + " ");
                    }
                }
                System.out.println();
                m--;
            }
        }
    }
}
